<template>
		<view class="page">
			<text class="title">{{detail.title}}</text>
			<view class="time">
				<text>发表时间：{{detail.add_time | formatDate}}</text>
				<text>浏览：{{detail.click}}</text>
			</view>
			<view class="">
				<rich-text :nodes="detail.content"></rich-text>
			</view>
		</view>
</template>

<script>
	export default {
		
		data() {
			return {
				detail:{},
				id:0
			};
		},
		onLoad(options) {
			this.id=options.id
			this.getNewsDetail()
			
			console.log(options)
		},
		methods: {
			//发起获取资讯详情数据请求
			async getNewsDetail() {
				const res = await uni.request({
					url: 'http://localhost:8082/api/getnew/' + this.id
				})
				console.log(res)
				const data = res[1].data
				if (data.status !== 0) {
					return uni.showToast({
						title: '获取数据失败'
					})
				} else {
					this.detail = data.message[0]
				}
			}
		}
	}
</script>

<style lang="less">
	.page {
		padding: 20rpx;
		font-size: 30rpx;
		.title{
			text-align: center;
			display: block;
		}
		.time{
			display: flex;
			justify-content: space-between;
			margin: 20rpx  0rpx 15rpx ;
			font-size: 25rpx;
		}
	}
</style>
